package com.itheima.admin.service.impl;

import com.itheima.admin.mapper.ModuleMapper;
import com.itheima.admin.mapper.UserMapper;
import com.itheima.admin.service.IModuleService;
import com.itheima.pojo.dto.ModuleDto;
import com.itheima.pojo.pojo.Module;
import com.itheima.pojo.pojo.User;
import com.itheima.pojo.vo.ModuleVo;
import com.itheima.pojo.vo.UserVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ModuleServiceImpl implements IModuleService {
    @Autowired
    private ModuleMapper moduleMapper;

    @Override
    public ModuleVo queryById(String id) {
        Module module=moduleMapper.selectById(id);
        ModuleVo moduleDto=new ModuleVo();

        BeanUtils.copyProperties(module,moduleDto);
        return moduleDto;
    }

    @Override
    public boolean updateModule(ModuleDto moduleDto) {
        Module module=new Module();
        boolean flag;
        BeanUtils.copyProperties(moduleDto,module);
        int i=  moduleMapper.updateById(module);
        if(i>0){
            flag=true;
        }
        else {
            flag=false;
        }
        return flag;

    }
}
